package com.smartticket.jeju.repository;

import java.sql.SQLException;
import java.util.HashMap;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.ibatis.sqlmap.client.SqlMapClient;
import com.smartticket.jeju.model.Sight;

@Repository
public class SightRepositoryImplByIbatis implements SightRepository
{
	@Autowired
	private SqlMapClient sqlMapClient;

	public Sight findById(int id) 
	{
		Map<String, Integer> param = new HashMap<String, Integer>();
		param.put("id", id);
		try 
		{
			return (Sight)this.sqlMapClient.queryForObject("Sight.selectSight", param);
		} 
		catch (SQLException e) 
		{
			e.printStackTrace();
			return null;
		}
	}

	public String getSightName(int sight_id) {
		Map<String, Integer> param = new HashMap<String, Integer>();
		param.put("id", sight_id);
		
		try
		{
			return (String)sqlMapClient.queryForObject("Sight.selectSightName", param);
		}
		catch(SQLException e)
		{
			e.printStackTrace();
			return null;
		}
	}
}
